#!/bin/sh -e
#
# Copyright (c) 2009-2020 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later

id="$(git rev-parse --verify "${1:-@}^{commit}")"

distdir=Linux-PAM-dist-$$
abs_distdir="`pwd`/$distdir"
trap 'chmod -Rf u+w $abs_distdir; rm -rf $abs_distdir' 1 2 15 0

set -x
git clone -q -n -s .git "$distdir"

cd $distdir
git config advice.detachedHead false
git checkout -f "$id"

mkdir build
meson setup --buildtype=debugoptimized -Dwerror=true build
meson dist -C build
mv -f build/meson-dist/Linux-PAM-*.tar.* ..
